﻿using Gym.Application.Common.Interfaces;
using Gym.Domain.SubscriptionAggregate.Events;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gym.Application.Gyms.Events
{
    public class GymAddedEventHandler : INotificationHandler<GymAddedEvent>
    {
        private readonly IGymsRepository _gymsRepository;

        public GymAddedEventHandler(IGymsRepository gymsRepository)
        {
            _gymsRepository = gymsRepository;
        }

        public async Task Handle(GymAddedEvent notification, CancellationToken cancellationToken)
        {
            await _gymsRepository.AddGymAsync(notification.Gym);
        }
    }
}
